<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" name="" id="aaa">
    <button>确定</button>
    <script>
        var a = document.getElementById('aaa').value
        var btn = document.querySelector('button')
        btn.addEventListener('click',result)

        function result() {
            console.log(a)
        }
    </script>
</body>
</html>